<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/static/jquery-easyui/themes/default/easyui.css"/>">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/static/jquery-easyui/themes/icon.css"/>">
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/jquery-1.6.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/plugins/jquery.panel.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/plugins/jquery.datagrid.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/plugins/jquery.messager.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/ext-for-framework.js.jsp"/>"></script>
<script type="text/javascript"
	src="<c:url value="/static/jquery-easyui/locale/easyui-lang-zh_CN.js"/>"></script>
<script type="text/javascript">
	function initList(listDisplayEId) {
		$('#' + listDisplayEId).datagrid({
			url : "<c:url value='/customer/similarcustomerlist.do'/>",
			/* queryParams: {
				codeType: $('#codeType').combobox('getValue')
			}, */
			nowrap : false,
			striped : true,
			collapsible : true,
			remoteSort : false,
			notSelectByRow : false,
		/* 	frozenColumns : [ [ {
				field : 'ids',
				checkbox : true
			} ] ], */

			onLoadError : function() {
				$.messager.alert('错误', '获取数据失败，请与管理员联系！', 'error');
			} ,
			onClickRow:function(rowIndex){
				$(".myrad").prop("checked",false);
				$(".myrad").eq(rowIndex).prop("checked",true);
			} 
			
		});
	};
	function formatterdate(val) {
		return val.substr(0, 11);
	}
	function formatterstatus(val) {
		var status="";
		$.ajax({
			url : "<c:url value='/datadictionary/getcodename.do'/>",
			async : false,
			data : {
				codeId : val,
				codeTypeId : "similar_deal_status"
			},
			dataType : 'json',
			success : function(data) {
				//status =  data.codeName;
				//alert(data);
				status = data.codeName;
			}

		});
		//alert(status);
		//return status;
		return status;
	}
	$(document).ready(function() {
		initList('listDisplay');
		initCertType();
		initGender();
		initsimilar_deal_status();
	});
	function searchDGData() {
	
		$('#listDisplay').datagrid('load', {
			cusName : $('#cusName').val(),
			gender : $('#gender').combobox('getValue'),
			certType : $('#certType').combobox('getValue'),
			certNo : $('#certNo').val(),
			cifId : $('#cifId').val(),
			degreeId : $('#degreeId').combobox('getValue')
		});
	}
	function initCertType() {
		$('#certType')
				.combobox(
						{
							url : "<c:url value='/datadictionary/datadictionarylistcombo.do?codeType=certificate_type'/>",
							valueField : 'codeId',
							textField : 'codeName',
							panelWidth : '220',
							onSelect : function(record) {
								// $('#certType').value = record.codeId;
								//codeTypeIdVal = record.codeId;
								//getInputType2(record.code);
							},
							/* formatter:function(row){
								return row.code + "-" + row.codename;
							}  */
							onLoadSuccess : function(data) {
								if (data) {
									$('#certType').combobox('select', null);
								}
							}

						});
	}
	function initGender() {
		$('#gender')
				.combobox(
						{
							url : "<c:url value='/datadictionary/datadictionarylistcombo.do?codeType=gender'/>",
							valueField : 'codeId',
							textField : 'codeName',
							panelWidth : '220',
							onSelect : function(record) {
								//$('#gender').value = record.codeId;
								//codeTypeIdVal = record.codeId;
								//getInputType2(record.code);
							},
							/* formatter:function(row){
								return row.code + "-" + row.codename;
							}  */
							onLoadSuccess : function(data) {
								if (data) {
									$('#gender').combobox('select', null);
								}
							}

						});
	}
	
	function initsimilar_deal_status() {
		$('#degreeId')
				.combobox(
						{
							url :  "<c:url value='/datadictionary/datadictionarylistcombo.do?codeType=similar_deal_status'/>",
							valueField : 'codeId',
							textField : 'codeName',
							panelWidth : '220',
							onSelect : function(record) {
							},
						 
							onLoadSuccess : function(data) {
								if (data) {
									$('#degreeId').combobox('select', null);
								}
							}

						});
	}
	function formatOptionField(value, row, index, field) {
		//alert(row.cifCusId+"&"+row.relCifId);
		//return "<span style='color:red'><a href='#' onclick='details(\"23333@333\");'>查看详细</a></span>";
		return "<span style='color:red'><a href='#' onclick='details("+row.cifCusId+","+row.relCifId+","+row.similarId
		+ ")'>查看详细</a></span>";
	}
	function formatDetail(value, row, index, field) {
 		return "<span style='color:red'><a href='#' onclick='detail(" + value
				+ ",this)'>"+value+"</a></span>";
	}
	function details(cifCusId,relCifId,similarId) {
		//window.showModalDialog("<c:url value='/customer/getsifcusinfos.do?cifCusId="+cifCusId+"&relCifId="+relCifId+"&similarId="+similarId+"'/>","","dialogWidth=1300px;dialogHeight=600px,status=no");
		
		var new_win = window.open("<c:url value='/jsp/openIndexSun.jsp?url=/customer/getsifcusinfos.do'/>","sun","width=1200px,height=600px,status=no,scrollbars=yes");
        new_win.focus();
		$('#listDisplay').datagrid('reload');
	}
	function formatRadio(value,rowData,rowIndex){
		return value="<input type='radio' class='myrad'  name='radioCustomer' />";
	}
	function detail(value) {
		var new_win = window.open("<c:url value='/jsp/openIndexSun.jsp?/customer/getsifcusmaininfo.do?cifCusId="+value+"'/>","sun","width=1200px,height=600px,status=no,scrollbars=yes");
        new_win.focus();
	}
</script>
</head>
<body>
	<!-- <div style="height: auto; background: #fafafa; padding: 5px;"
		class="easyui-panel" title="查询" iconCls="icon-search"
		collapsible="true" minimizable="false" maximizable="false"
		closable="false"> -->
		<div class="easyui-panel" title="查询" iconCls="icon-search" style="width:1180px;"> 
		<form id="searchForm" name="searchForm" method="post">
			<table >
				<thead>
					<tr>
						<td>姓名</td>
						<td><input type="text" id="cusName"  name="cusName"></td>
						<td style="width: 10px"></td>
						<td>性别</td>
						<td><input id="gender" name="gender" style="width: 60px;"></td>
						<td style="width: 10px"></td>
						<td><label for="StartDate" >证件类型:</label></td>
						<td><input name="certType" style="width: 80px;" id="certType" /></td>
						<td style="width: 10px"></td>
						<td>证件号码</td>
						<td><input type="text" id="certNo" name="certNo"></td>
						<td style="width: 10px"></td>
						<td>CIFID</td>
						<td><input type="text" id="cifId" style="width: 80px;" name="cifId"></td>
						 <td style="width: 10px"></td>
						<td>合并状态</td>
						<td><input id="degreeId" name="degreeId" style="width: 60px;"></td>
						<td style="width: 10px"></td>
						<td style="width: 10px"></td>
						<td><input type="button" value="查询" onclick="searchDGData()" /></td>
						<!-- <th><a href="javascript:searchDGData()" class="easyui-linkbutton" plain="true" icon="icon-search">查询</a></td> -->
					</tr>
				</thead>
				<tbody>
				</tbody>
			</table>
		</form>
	</div>
	<br/>
	<table id="listDisplay" title="客户合并" iconCls="icon-list"
		singleSelect="true" fitColumns="true" idField="id"
		loadMsg="请稍候......" pagination="true" pageSize="10"
		pageList="[5,10,20,30,40,50,100,150,200]" sortName="updateTime"
		rownumbers="true" sortOrder="desc" style="width:1180px;">
		<thead>
			<tr>
				<%--<td field="fhCodeId" width="250" sortable="true"
						formatter="formatDGField" >
						fhCodeId
					</td>--%>
				<!-- <th field="CodeType" id="codeType" hidden="true" value="1"> -->
				<!-- <th field="similarId" hidden="true"></th> -->
				<th field="radioRole" width="25" align="center" formatter="formatRadio"  >
				<th field="similarId" hidden="true"></th>
				<th field="cifCusId" width="80" sortable="true" editor="text" formatter="formatDetail">
					主客户CIFID</th>

				<th field="customerName" width="80" sortable="true" editor="text">
					姓名</th>
				<th field="gender" width="80" sortable="true" editor="text">性别</th>
				<th field="relCifId" width="80" sortable="true" editor="text" formatter="formatDetail">
					疑似客户CIFID</th>
				<th field="dealStatus" width="80" formatter="formatterstatus"
					sortable="true">合并状态</th>
				<th field="insertTime"  width="160" sortable="true">插入时间</th>
				<th field="updateTime"  width="160" sortable="true">更新时间</th>
				<!-- 
					<th field="isActive" width="80" formatter="formatIsActive" sortable="true" editor="{type:'combobox',options:{required:true,valueField:'isActive',textField:'isa',data:[{isAcitve:'1','isa':'可用'},{isAcitve:'0','isa':'不可用'}]}}">

						是否可用
					</th>
					 -->

				<th field="button" width="260" align="center"
					formatter="formatOptionField">操作</th>


			</tr>
		</thead>
	</table>
</body>
</html>